<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>

    </div>
</body>
<script>
    //1.创建对象
    let xhr
    if (XMLHttpRequest) {
        xhr=new XMLHttpRequest()
    }else{
        xhr=new ActiveXObject('Microsoft.XMLHTTP')
    }
    //2.打开链接
    xhr.open("post", 'http://192.168.102.4:3000/users/test', true)
    //3.设置请求头
    xhr.setRequestHeader('content-type','application/x-www-form-urlencoded')
    //4.发送数据
    xhr.send('username=tom,password=123456')
     //5.监听状态变化
     xhr.onreadystatechange=function(e){
         if(xhr.readyState === 4 && xhr.status === 200) {
      console.log(xhr.response)
         }

     }
</script>
</html>